main(a,b,t)
{
	for(gets(&a);~scanf("%d%d",&a,&b);printf("%d\n",a))
		while(b)
		{
			t=a%b;
			a=b;
			b=t;
		}
}
